package com.prs.crm.service.pm.impl;

import java.io.File;
import java.util.Collection;

import com.prs.crm.context.FileUtil;
import com.prs.crm.dao.pm.PmDocDao;
import com.prs.crm.domain.Attachment;
import com.prs.crm.domain.pm.PmDoc;
import com.prs.crm.domain.pm.PmProject;
import com.prs.crm.domain.pm.PmStage;
import com.prs.crm.service.impl.BaseServiceImpl;
import com.prs.crm.service.pm.PmDocService;

public class PmDocServiceImpl extends BaseServiceImpl<PmDoc,PmDocDao> implements PmDocService{

	@Override
	public Collection<PmDoc> getPmDoc(PmProject project, PmStage stage) {
		// TODO Auto-generated method stub
		return this.getDao().getPmDoc(project,stage);
	}

	@Override
	public void submitPmDoc(PmDoc pmDoc, File file, String fileName) {
		// TODO Auto-generated method stub
		Attachment attach = FileUtil.getInstance().createAttach(file, fileName);
		if(attach != null) {
			pmDoc.setAttach(attach);
		}
		this.save(pmDoc);
	}

	@Override
	public Collection<PmDoc> getPmDoc(PmProject project) {
		// TODO Auto-generated method stub
		return this.getDao().getPmDoc(project);
	}

	@Override
	public Collection<PmDoc> getProjectCreateDoc(PmProject project) {
		// TODO Auto-generated method stub
		return this.getDao().getProjectCreateDoc(project);
	}

}
